Sensor Fusion for Kinetis MCUs (ISSDK/KSDK version)
motionCheck.c File Reference
+ Include dependency graph for motionCheck.c:

Go to the source code of this file.

Functions

bool motionCheck (float sample[3], float baseline[3], float tolerance, uint32_t winLength, uint32_t *count)
 

Detailed Description

This function would normally be called from your fusion_tasks in your main.c. See main_freertos_two_tasks_power_cycling.c for example usage.

Definition in file motionCheck.c.

Function Documentation

bool motionCheck ( float  sample[3],
float  baseline[3],
float  tolerance,
uint32_t  winLength,
uint32_t *  count 
)

The motionCheck() function is not a sensor fusion function. It is a function that simply monitors an accelerometer or magnetometer tri-axial sensor output, returning Boolean true if the sensor appears to be stationary, and false otherwise. This function would normally be called from your fusion_tasks in your main().

Parameters
sampleprocessed triaxial sensor sample (accel or mag)
baselineprevious value to compare to
tolerancehow much tolerance you can stand
winLengthhow many samples need to be stable to assert "noMotion"
counthow many samples so far we've been not moving

Definition at line 44 of file motionCheck.c.

Referenced by fusion_task(), and vApplicationTickHook().

51 {
52  float change[3];
53  bool changed;
54  change[CHX] = fabs(baseline[CHX] - sample[CHX]);
55  change[CHY] = fabs(baseline[CHY] - sample[CHY]);
56  change[CHZ] = fabs(baseline[CHZ] - sample[CHZ]);
57  changed = (change[CHX]>tolerance) ||
58  (change[CHY]>tolerance) ||
59  (change[CHZ]>tolerance);
60  if (changed) {
61  baseline[CHX] = sample[CHX];
62  baseline[CHY] = sample[CHY];
63  baseline[CHZ] = sample[CHZ];
64  *count = 0;
65  } else {
66  if ((*count) <= winLength) (*count) += 1;
67  }
68  return(*count > winLength);
69 }
#define CHY
Used to access Y-channel entries in various data data structures.
Definition: sensor_fusion.h:77
#define CHZ
#define CHX
Used to access X-channel entries in various data data structures.
Definition: sensor_fusion.h:76

+ Here is the caller graph for this function: